package org.tio.http.server.showcase.controller;

import org.tio.http.common.HttpRequest;
import org.tio.http.common.HttpResponse;
import org.tio.http.server.annotation.RequestPath;
import org.tio.http.server.util.Resps;
import org.tio.utils.jfinal.P;

/**
 * @author tanyaowu
 */
@RequestPath(value = "/")
public class HelloController {
	@RequestPath(value = "")
	public HttpResponse index(HttpRequest request, String who) throws Exception {
		String name = who == null ? "World" : who;
		String html = "<title>Hello " + name + "</title><h1>Hello " + name + "</h1>";
		html += "<div>" + P.get("app.name") + " " + P.get("app.version") + "</div>";
		html += "<div>Powered by <a href='https://t-io.org' target='_blank'>" + org.tio.http.common.HttpConst.SERVER_INFO + " " + org.tio.utils.SysConst.TIO_CORE_VERSION + "</a></div>";
		return Resps.html(request, html);
	}
}